package com.system.appointment.service.impl;

import com.system.appointment.service.RefundStrategy;

import java.time.LocalDate;
import java.time.temporal.ChronoUnit;

/**
 * @className: RefundStrategyFactory
 * @description: TODO 类描述
 * @author: Li Chuanwei
 * @date: 2023/12/12 16:18
 * @Company: Copyright [日期] by [作者或个人]
 **/

public class RefundStrategyFactory {
    public static RefundStrategy createRefundStrategy(String date) {
        LocalDate createTime = LocalDate.parse(date);
        LocalDate currentDate = LocalDate.now();
        long diffInDays = ChronoUnit.DAYS.between(currentDate, createTime);

        if (diffInDays <= 0) {
            return new OneDayRefundStrategy();
        } else {
            return new DefaultRefundStrategy();
        }
    }

}
